<template>
  <el-container style="min-height: 100vh">
    <el-aside
      :width="sideWidth + 'px'"
      style="box-shadow: 2px 0 6px rgb(0 21 41)"
    >
      <el-menu
        :default-openeds="['1', '3']"
        style="min-height: 100%; overflow-x: hidden"
        background-color="rgb(48, 65, 86)"
        text-color="#fff"
        active-text-color="#ffd04b"
        :collapse-transition="false"
        :collapse="isCollapse"
      >
        <div style="height: 60px; line-height: 60px; text-align: center">
          <img
            src="@/assets/logo.png"
            alt=""
            style="width: 20px; position: relative; top: 5px; right: 5px"
          />
          <b style="color: white" v-show="logoTextShow">后台管理系统</b>
        </div>
        <el-submenu index="1">
          <template slot="title">
            <i class="el-icon-message"></i>
            <span slot="title">后台主页</span>
          </template>
          <!-- <el-menu-item index="1-0"
            ><router-link class="routerto" to="/" >后台管理主页</router-link></el-menu-item
          > -->
          <el-menu-item index="1-1"
            ><router-link class="routerto" to="/goodsManage"
              >商品后台管理</router-link
            ></el-menu-item
          >
          <el-menu-item index="1-2"
            ><router-link class="routerto" to="/user">用户后台管理</router-link></el-menu-item
          >
          <el-menu-item index="1-2"
            ><router-link class="routerto" to="/order">订单后台管理</router-link></el-menu-item
          >
        </el-submenu>
      </el-menu>
    </el-aside>

    <el-container>
      <el-header
        style="
          font-size: 12px;
          border-bottom: 1px solid #ccc;
          line-height: 60px;
          display: flex;
        "
      >
      </el-header>
      <div style="margin: auto">
        <h1>管理员你好，欢迎来到后台管理页面</h1>
      </div>
    </el-container>
  </el-container>
</template>

<script>
import router from "../../router";

export default {
  mounted() {
    this.cheackAdmin();
  },
  methods: {
    cheackAdmin() {
      this.$axios
        .get("/admin/index", {
          headers: {
            "x-access-token": localStorage.getItem("x-access-token"),
          },
        })
        .then((res) => {
          console.log(res);
          if (res.data.code == 401 && "用户不存在！" == res.data.extend.result) {
            this.$message.error("请先登录再访问后台");
            router.push("./login");
          } else if (
            res.data.code == 401 &&
            "登录失败，该用户没有权限" == res.data.extend.result
          ) {
            this.$message.error("登录失败，该用户不是管理员");
               router.push("./login");
          }else if (
            res.data.code == 401 &&
            "该用户已被锁定,暂时无法登录！" == res.data.extend.result
          ) {
            this.$message.error("登录失败，该用户不是管理员");
               router.push("./login");
          }
          
          else if (
            res.data.code == 200 &&
            "登陆成功" == res.data.extend.result
          ) {
            this.$message({
              message: "管理员你好，欢迎来到后台管理页面",
              type: "success",
            });
            
          }
        });
    },
  },
};
</script>


<style>
.headerBg {
  background: #eee !important;
}
.routerto{
  color: #fff;
  text-decoration: none;

}
</style>
